package com.utils.httphelper;

import java.util.Arrays;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

public class PCOrWechat {
	/**
	    * 判断 移动端/PC端
	    * @Title: isMobile
	    * @author: pk
	    * @Description: TODO
	    * @param request
	    * @return
	    * @return: boolean
	    */
	   public static boolean isMobile(HttpServletRequest request) {
	      List<String> mobileAgents = Arrays.asList("android", "iphone", "ipod", 
				"ipad", "rv:1.2.3.4", "ucweb", "windows ce", "windows mobile", "windows phone");
	      String ua = request.getHeader("User-Agent").toLowerCase();
	      for (String sua : mobileAgents) {
	         if (ua.indexOf(sua) > -1) {
	            return true;//手机端
	         }
	      }
	      return false;//PC端
	   }
	   
	   /**
	    * 是否微信浏览器
	    * @Title: isWechat
	    * @author: pk
	    * @Description: TODO
	    * @param request
	    * @return
	    * @return: boolean
	    */
	   public static boolean isWechat(HttpServletRequest request) {
	      String ua = request.getHeader("User-Agent").toLowerCase();
	         if (ua.indexOf("micromessenger") > -1) {
	            return true;//微信
	         }
	      return false;//非微信手机浏览器
	      
	   }


}
